feat(chat): require events$ on Agent contract with structured AgentEvent union#138
Merged
Conversation
Replace optional customEvents$ with required events$ carrying a discriminated union (AgentStateUpdateEvent | AgentCustomEvent). Codify invariant: state on signals, events on events$, no duplication. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
3 tasks: rewrite agent-event types + chat-side rewiring (single commit due to intermediate breakage), langgraph adapter translation, final verify + PR. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ent union Replaces optional customEvents$: Observable<AgentCustomEvent> with required events$: Observable<AgentEvent>. AgentEvent discriminates state_update from generic custom events. Codifies invariant: state on signals, events on events$, no duplication. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
toAgent(ref) now emits events$: Observable<AgentEvent>. Translates state_update events into AgentStateUpdateEvent (with data: Record), all others into the structured AgentCustomEvent escape hatch. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
customEvents$: Observable<AgentCustomEvent>(free-form) with requiredevents$: Observable<AgentEvent>(structured discriminated union).AgentEvent = AgentStateUpdateEvent | AgentCustomEvent.state_updateis a structured variant withdata: Record<string, unknown>;customis the escape hatch carrying{ name, data: unknown }.CustomStreamEvent→AgentEvent, discriminatingstate_updatewhendatais a Record.events$, no duplication.Motivation
The previous
customEvents$was optional and free-form, forcing every consumer to null-check and trust untyped payloads. Making it required + structured eliminates both frictions and gives a clear addition path for future well-known event types.Test Plan
nx run-many -t lint,test,build -p chat,langgraphpassesnx affected -t buildpassescustomEvents\$onAgentcontract; cockpit unaffected (no consumers outsidechat.component.ts)Design + plan
docs/superpowers/specs/2026-04-25-events-on-agent-contract-design.mddocs/superpowers/plans/2026-04-25-events-on-agent-contract.md🤖 Generated with Claude Code